function updateTextColor(el, value) {
  const color = value > 0 ? '#ff2436' : value < 0 ? '#07AB4B' : 'inherit';
  el.style.color = color;
}

export default Vue => {
  Vue.directive('redGreen', {
    bind(el, binding) {
      updateTextColor(el, parseFloat(binding.value));
    },
    update(el, binding) {
      updateTextColor(el, parseFloat(binding.value));
    },
  });
};
